package servlet;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Servlet implementation class TestInclude
 */
public class TestInclude extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public TestInclude() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
//		PrintWriter pw = response.getWriter();
//		
//		String uri = request.getRequestURI();
//		String contextPath = request.getContextPath();
//		uri = uri.substring(contextPath.length() + 1);
//		
//		pw.println(uri + "<br>");
//		
//		pw.println(request.getServletPath());
		
		System.out.println(request.getCharacterEncoding());
		request.setCharacterEncoding("utf-8");
		
		System.out.println(request.getParameter("name"));
		System.out.println(request.getParameter("cnName"));
//		pw.println(request.getPathInfo());
//		RequestDispatcher rd = request.getRequestDispatcher("/TestInclude1");
//		rd.include(request, response);
//		
//		pw.println(request.getAttribute("javax.servlet.include.servlet_path"));
//		pw.println(this.getServletContext().getRealPath(request.getServletPath()));
//		pw.flush();
		
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
